package swordRefersOffer.p15;

/**
 * @author: trtan
 * @date: 2021-06-23 06:54
 **/
public class BinaryOneNumber {
    public static void main(String[] args) {
        int n = 0b01011;
        System.out.println(new BinaryOneNumber().hammingWeight(n));
    }
    public int hammingWeight(int n) {
        System.out.println(n);
        int count = 0;
        while (n != 0) {
            n = n & (n - 1);
            count++;
        }
        return count;
    }
}
